<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Downloadspeed
 *
 * @author yves.peeters
 */
class Downloadspeed {
    private $t1 = 99000; //kbps
    private $dialup = 56;// kbps
    private $isdn = 128;

    private function bits2Bytes($bits){
        $bytes = $bits/8;
        return $bytes;
    }

    private function Kilobits2Bits($kbits){
        return $kbits*1000;
    }

    private function bytes2Kilobytes($bytes){
        return $bytes / 1024;
    }

    private function kilobytestobytes($kilobytes){
        return $kilobytes *1024;
    }

    public function timeWithT1($size){ // size in bytes
        $bits = $this->Kilobits2Bits($this->t1);
        $speedInKilobytes = $this->bits2Bytes($bits)/1024;
        return  round($size /$speedInKilobytes);
    }
    public function timeWithDialup($size){
         $bits = $this->Kilobits2Bits($this->dialup);
        $speedInKilobytes = $this->bits2Bytes($bits)/1024;
        return  round($size /$speedInKilobytes);
    }
    public function timeWithISDN($size){
         $bits = $this->Kilobits2Bits($this->isdn);
        $speedInKilobytes = $this->bits2Bytes($bits)/1024;
        return  round($size /$speedInKilobytes);
    }
}
?>
